package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.CategoryServiceZxw;
import com.atguigu.spzx.model.entity.product.Category;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/zxw/admin/product/category")
public class CategoryControllerZxw {
    @Autowired
    private CategoryServiceZxw categoryServiceZxw;

    @GetMapping("/test001")
    public Result test001() {
        System.out.println("success");
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/findByParentId/{parentId}")
    public Result<List<Category>> findByParentId(@PathVariable("parentId") Long parentId) {
        List<Category> categoryList = categoryServiceZxw.findCategoryList(parentId);
        return Result.build(categoryList, ResultCodeEnum.SUCCESS);
    }



}
